﻿@using Commission.Models
@using MyResources = Commission.Resources.AppResource
@model LoginViewModel

@{
    ViewBag.Title = @MyResources.LabelLogin;
    var culture = System.Threading.Thread.CurrentThread.CurrentUICulture.Name.ToLowerInvariant();
}

@section MyJavascript {
    <script type="text/javascript">
        $(document).ready(function () {
            $("input[type = 'radio']").click(function () {
                $(this).parents("form").submit(); // post form
            });
        })
    </script>
}

@helper selected(string c, string culture)
{
    if (c == culture)
    {
        @:checked="checked"
    }
}

<h2>@ViewBag.Title</h2>
<hr />
         
<div class="row">
    <div class="col-md-8">
        <section id="loginForm">
            
            @Html.ValidationSummary(true, "", new { @class = "text-danger" })

            @using (Html.BeginForm("SetCulture", "Account", 
                FormMethod.Get, new { @class = "form-horizontal" }))
            {
                <div class="form-group">
                    @Html.Label(" ", new { @class = "col-md-2 control-label" })

                    <div class="col-md-10">
                        <input name="culture" id="vi-vn"
                                value="vi-vn" type="radio" @selected("vi-vn", culture) /> @Html.Raw("Tiếng Việt　")
                        <input name="culture" id="zh-cn"
                                value="zh-cn" type="radio" @selected("zh-cn", culture) /> @Html.Raw("中文")
                    </div>
                </div>
            }

            @using (Html.BeginForm("Login", "Account", new { ReturnUrl = ViewBag.ReturnUrl },
                FormMethod.Post, new { @class = "form-horizontal", role = "form", @autocomplete = "off" }))
            {
                @Html.AntiForgeryToken()

                <div class="form-group">
                    @Html.Label(@MyResources.LabelUserName, new { @class = "col-md-2 control-label" })

                    <div class="col-md-10">
                        @Html.TextBoxFor(m => m.UserName, new { @class = "form-control" })
                        @Html.ValidationMessageFor(m => m.UserName, "", new { @class = "text-danger" })
                    </div>
                </div>
                
                <div class="form-group">
                    @Html.Label(@MyResources.LabelPassword, new { @class = "col-md-2 control-label" })
                    <div class="col-md-10">
                        @Html.PasswordFor(m => m.Password, new { @class = "form-control" })
                        @Html.ValidationMessageFor(m => m.Password, "", new { @class = "text-danger" })
                    </div>
                </div>
                
                <div class="form-group">
                    <div class="col-md-offset-2 col-md-10">
                        <input type="submit" value="@MyResources.LinkLogin" class="btn btn-default" />
                    </div>
                </div>
                @*
                <p>
                    @Html.ActionLink("Register as a new user", "Register")
                </p>
                 Enable this once you have account confirmation enabled for password reset functionality
                <p>
                    @Html.ActionLink("Forgot your password?", "ForgotPassword")
                </p>*@
            }
        </section>
    </div>
</div>

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}